<template>
  <div id="changedialog">
    <commonformdialog
      :isshowDialogs="isshowDialog"
      :dialogTitle="dialogTitle"
      @closetextDialog="closetextDialog"
      @confirmbtn="confirmbtn"
      :dialogWidth="'750px'"
    >
      <div class="innerLoding">
        <el-row>
          <el-form
            :model="formData"
            :rules="rules"
            ref="ruleForm"
             placeholder="请选择地址"
            label-width="120px"
            size="small"
          >
            <el-col :span="24">
              <el-form-item label="企业名称：" prop="name">
                <el-input
                  placeholder="请输入企业名称"
                  type="text"
                  clearable
                  v-model="formData.name"
                >
                </el-input>
              </el-form-item>
            </el-col>
             <el-col :span="24">
              <el-form-item label="曾用名：" prop="name_old">
                <el-input
                  placeholder="请输入曾用名"
                  type="text"
                  clearable
                  v-model="formData.name_old"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="驾校名称：" prop="school_name">
                <el-input
                  placeholder="请输入驾校名称"
                  type="text"
                  clearable
                  v-model="formData.school_name"
                >
                </el-input>
              </el-form-item>
            </el-col>
  
            <el-col :span="24">
              <el-form-item label="班型价格：" prop="price">
                <el-input
                  placeholder="请输入班型价格"
                  type="text"
                  clearable
                  v-model="formData.price"
                >
                </el-input>
              </el-form-item>
            </el-col>
           
            <el-col :span="24">
              <el-form-item label="所在城市：" prop="city_id">
                <el-cascader
                  ref="cascader"
                  filterable
                  v-model="formData.city_id"
                  :options="cityoptions"
                  :props="{ expandTrigger: 'hover', checkStrictly: true ,emitPath:false}"
                  clearable
                  :show-all-levels="false"

                  style="width:100%"
                ></el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="所在地区：" prop="area_id">
                <el-cascader
                  ref="cascader"
                  filterable
                  v-model="formData.area_id"
                  :options="areaoptions"
                  :props="{ expandTrigger: 'hover', checkStrictly: true,emitPath:false }"
                  clearable
                  :show-all-levels="false"
                  style="width:100%"
                ></el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="法人代表：" prop="legal_man">
                <el-input
                  placeholder="请输入法人代表"
                  type="text"
                  clearable
                  v-model="formData.legal_man"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="注册资本：" prop="register_capital">
                <el-input
                  placeholder="请输入注册资本"
                  type="text"
                  clearable
                  v-model="formData.register_capital"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="社会信用代码：" prop="credit_code">
                <el-input
                  placeholder="请输入社会信用代码"
                  type="text"
                  clearable
                  v-model="formData.credit_code"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="企业地址：" prop="addr">
                <el-input
                  placeholder="请输入企业地址"
                  type="text"
                  clearable
                  v-model="formData.addr"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="联系地址：" prop="addr_new">
                <el-input
                  placeholder="请输入联系地址"
                  type="text"
                  clearable
                  v-model="formData.addr_new"
                >
                </el-input>
              </el-form-item>
            </el-col>
        
            <el-col :span="24">
              <el-form-item label="联系邮箱：" prop="email">
                <el-input
                  placeholder="请输入联系邮箱"
                  type="text"
                  clearable
                  v-model="formData.email"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="网址：" prop="website">
                <el-input
                  placeholder="请输入网址"
                  type="text"
                  clearable
                  v-model="formData.website"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="参保人数：" prop="insurance_num">
                <el-input
                  placeholder="请输入参保人数"
                  type="number"
                  clearable
                  v-model="formData.insurance_num"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="企业类型：" prop="type">
                <el-input
                  placeholder="请输入企业类型"
                  type="text"
                  clearable
                  v-model="formData.type"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="所属行业：" prop="industry">
                <el-input
                  placeholder="请输入所属行业"
                  type="text"
                  clearable
                  v-model="formData.industry"
                >
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="经营范围：" prop="business_scope">
                <el-input
                  placeholder="请输入经营范围"
                  type="text"
                  clearable
                  v-model="formData.business_scope"
                >
                </el-input>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="成立日期：" prop="setup_date">
                <el-date-picker
                  v-model="formData.setup_date"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择成立日期"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item label="核准日期：" prop="approv_date">
                <el-date-picker
                  v-model="formData.approv_date"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="请选择核准日期"
                  style="width: 100%"
                >
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="24">
              <el-form-item label="登记状态：" prop="status">
                <el-select
                  v-model="formData.status"
                  placeholder="请选择登记状态"
                  style="width: 100%"
                  filterable
                  clearable
                >
                  <el-option
                    v-for="item in statusOptions"
                    :key="item.id"
                    :label="item.title"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-form>
        </el-row>
      </div>
    </commonformdialog>
  </div>
</template>

<script type="text/javascript">
//引入弹窗
import commonformdialog from "@/components/commondialog/commondialog";
import uploadimg from "@/components/uploadimg/uploadimg";
import { VEmojiPicker } from "v-emoji-picker";
import { schoolResourcesUpdate } from "@/api/schoolResources";
export default {
  data() {
    return {
      showPicker: false,
      multipleopen: true,
      imgList: [],
      formData: {
        name: "",
        city_id: "",
        legal_man: "",
      },
      rules: {
        // name: [{ required: true, message: "请输入企业名称", trigger: "blur" }],
        // city_id: [
        //   { required: true, message: "请输入所在城市", trigger: "blur" },
        // ],
        // legal_man: [{ required: true, message: "请输入法人代表", trigger: "blur" }],
      },

      statusOptions: [
        { title: "在业/存续/正常", id: 1 },
        { title: "迁出", id: 2 },
        { title: "仍注册", id: 3 },
        { title: "注销", id: 4 },
        { title: "核准设立", id: 5 },
      ],
    };
  },
  props: {
    //是否显示弹窗
    isshowDialog: {
      type: Boolean,
      default: false,
      required: true,
    },
    //表单的名字
    dialogTitle: {
      type: String,
      default: "",
      required: true,
    },
    //是编辑还是新增
    formType: {
      type: Number,
      default: 0,
    },
    cityoptions: {
      type: Array,
    },
    areaoptions: {
      type: Array,
    },
    dialogdata: {
      type: Object,
    },
  },
  components: {
    commonformdialog,
    uploadimg,
    VEmojiPicker,
  },
  methods: {
    changePicker() {
      this.showPicker = !this.showPicker;
    },
    closetextDialog() {
      this.$emit("closedialog");
    },

    confirmbtn() {
      this.$refs["ruleForm"].validate(async (valid) => {
        if (!valid) return;
        let params =  this.formData;
        let data = await schoolResourcesUpdate(params);

        if (data.code == "0000") {
          this.$message({
            type: "success",
            message: data.msg,
          });
          this.$emit("confirm");
        }
      });
    },
  },
  watch: {
    isshowDialog: function (val) {
      if (!val) {
        this.$refs["ruleForm"].resetFields();
      }
    },
    dialogdata: function (val) {
      this.formData = val;
    },
  },
  created() {},
};
</script>

<style lang="scss" scoped>
::v-deep {
  #InputSearch {
    display: none !important;
  }
  .grid-emojis {
    grid-template-columns: repeat(10, 10%) !important;
  }
  .small {
    position: absolute;
    z-index: 9;
    left: -45px;
    top: 30px;
  }
}
</style>
